package sunstar.com.xq.shortcut

import android.content.Context
import android.content.Intent
import android.content.pm.ShortcutInfo
import android.content.pm.ShortcutManager
import android.graphics.drawable.Icon
import sunstar.com.xq.R

/**
 * Created by Sun.Star on 2017/6/4.
 */
class ShortCutManager {
    companion object{
        fun initShortCut(context: Context){
            if(android.os.Build.VERSION.SDK_INT>=android.os.Build.VERSION_CODES.N_MR1){
                var shortCutList = mutableListOf<ShortcutInfo>()
                var shortCutManager = context.getSystemService(ShortcutManager::class.java)
                var shortInfo = ShortcutInfo.Builder(context,"id1")
                        .setShortLabel("大龙")
                        .setLongLabel("大龙")
                        .setIcon(Icon.createWithResource(context, R.mipmap.qq))
                        .setIntent(Intent(Intent.ACTION_VIEW).setClassName("sunstar.com.xq","sunstar.com.xq.activity.LoginActivity"))
                        .build()
                shortCutList.add(shortInfo)
                shortCutManager.setDynamicShortcuts(shortCutList)
            }
        }
    }

}